package com.yjck.fm.system.dao.impl;

import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;

import com.yjck.fm.common.BasicImpl;
import com.yjck.fm.system.bean.Menu;
import com.yjck.fm.system.dao.MenuDAO;
import com.yjck.fm.system.dao.handler.MenuRowHandler;

public class MenuDAOImpl extends BasicImpl implements MenuDAO{
	
	@SuppressWarnings("unchecked")
	public List<Menu> findMenuByParentId(String id) {
		List<Menu> menus = new ArrayList<Menu>();
		StringBuffer sql = new StringBuffer();
		sql.append("select * from menu where 1 = 1 ");
		if("".equals(id)||id == null){
			sql.append("and parentid = 0 ");
		}else{
			sql.append("and parentid = " + id);
		}
		menus = this.jdbcTemplate.query(sql.toString(), new MenuRowHandler());
		return menus;
	}

}
